using System;
using System.Net;
using System.Collections.Specialized;

namespace atomtask
{
	public partial class GlobalData
	{
		public static string host;

		public class RequestSender
		{	
			private NameValueCollection parameters;
			public delegate void completeDelegate(object s, UploadValuesCompletedEventArgs e);
			private completeDelegate complete;

			public RequestSender(string request)
			{
				parameters = new NameValueCollection();
				parameters.Add(new NameValueCollection(){
					{"r", request}
				});
			}
			public void addParameter(string key, string value)
			{
				parameters.Add(new NameValueCollection(){
					{key, value}
				});
			}
			public void addComplete(completeDelegate complete_)
			{
				complete = complete_;
			}
			public void send()
			{
				System.Net.WebClient web = new System.Net.WebClient ();
				web.UploadValuesCompleted += new UploadValuesCompletedEventHandler(this.complete);
				web.UploadValuesAsync(new Uri("http://"+ GlobalData.host), this.parameters);
			}
		}
	}
}

